KitePlayerMediaSession

class KitePlayerMediaSession(player: KitePlayer, skipInterval: Duration = 15.seconds) : AutoCloseable

Mirrors player into the iOS now playing card and routes its buttons back.

That card is what the lock screen, the control centre and CarPlay show, and the buttons are what a headset, a steering wheel and a watch send. Both are process-wide on iOS, so build one of these for the player the listener is hearing, and close it before building another. A button press that arrives after the player closed does nothing.

The audio session category the card needs is already the one the player's own output sets, so nothing has to change there. The application still declares the background audio capability itself if it wants the card to survive locking the screen.

Most apps get one from KitePlayer.attachMediaSession, which also adds background handling and interruption handling, and closes it all with the player.

Parameters

skipInterval

how far the skip back and skip forward buttons move, on the lock screen, the control centre, CarPlay and a headset. Positive.

Constructors

Link copied to clipboard
constructor(player: KitePlayer, skipInterval: Duration = 15.seconds)

Properties

Link copied to clipboard
val isAvailable: Boolean = true

Always true here. Other platforms answer false when they have no session, so one check works everywhere.

Link copied to clipboard
val platformToken: Any? = null

Apple has no token to hand out; the card is process-wide. Always null.

Functions

Link copied to clipboard
open override fun close()

Closes what this session owns, newest first, then the card. Only the first call does anything.

Link copied to clipboard
fun setArtwork(image: UIImage?)

The picture the card shows. Without one the card shows the item's own cover, the picture a music file carries, when it has one; a picture set here wins over it, and null goes back to it.